home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Utilities / SmartFilesystem / Include / objects.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-30  |  4.8 KB  |  162 lines

  1. #include <exec/types.h>
  2. #include <libraries/iffparse.h>
  3. #include "blockstructure.h"
  4. #include "nodes.h"
  5.  
  6. #define OBJECTCONTAINER_ID         MAKE_ID('O','B','J','C')
  7. #define HASHTABLE_ID               MAKE_ID('H','T','A','B')
  8. #define SOFTLINK_ID                MAKE_ID('S','L','N','K')
  9.  
  10. /* Below is the structure describing an Object.  Objects can be files or
  11.    directories.  Multiple Objects can be stored in an ObjectContainer
  12.    block.
  13.  
  14.    owneruid & ownergid:  These are not used at the moment.  They have
  15.    been reserved for future use.  They must be set to zero for now.
  16.  
  17.    objectnode:  This field contains a number uniquely identifying this
  18.    object.  This number can be used to find out the ObjectContainer
  19.    where the Object is stored in.  It is used to refer to an Object
  20.    without having to use BLCK pointers.
  21.  
  22.    protection:  Contains the Object's protection bits.  By default this
  23.    field is set to 0x0000000F, which means bits R, W, E and D are set
  24.    (note that this is opposite to what is used by AmigaDOS).
  25.  
  26.    data (files only):  Contains the BLCK number of the first data block of
  27.    a file.  To find out where the rest of the data is located this BLCK
  28.    number can be looked up in a special B+-Tree structure (see below).
  29.  
  30.    size (files only):  Contains the size of a file in bytes.
  31.  
  32.    hashtable (directories only):  A BLCK pointer.  It points to a
  33.    HashTable block.
  34.  
  35.    firstdirblock (directories only):  This BLCK pointer points to the
  36.    first ObjectContainer block which belongs to this directory object.
  37.    For empty directories this field is zero.
  38.  
  39.    datemodified:  The date of the last modification of this Object.  The
  40.    date is stored in seconds from 1-1-1978 (enough for storing 136 years)
  41.  
  42.    bits:  See the defines below.  At the moment this field can be checked
  43.    to see if the object is a file or directory.  A bit is reserved for
  44.    links, but isn't currently used (and may or may not be used depending
  45.    on how and if links are implemented).
  46.  
  47.    name:  Directly following the main structure is the name of the object.
  48.    It is zero terminated.
  49.  
  50.    comment:  Directly following the name of the object is the comment
  51.    field.  This field is zero terminated as well (even if there is no
  52.    comment). */
  53.  
  54. struct fsObject {
  55.   UWORD owneruid;
  56.   UWORD ownergid;
  57.   NODE  objectnode;
  58.   ULONG protection;
  59.  
  60.   union {
  61.     struct {
  62.       BLCK  data;
  63.       ULONG size;
  64.     } file;
  65.  
  66.     struct {
  67.       BLCK  hashtable;   /* for directories & root */
  68.       BLCK  firstdirblock;
  69.     } dir;
  70.   } object;
  71.  
  72.   ULONG datemodified;
  73.   UBYTE bits;
  74.  
  75.   UBYTE name[0];
  76.   UBYTE comment[0];
  77. };
  78.  
  79. #define OTYPE_HARDLINK (32)
  80. #define OTYPE_LINK     (64)
  81. #define OTYPE_DIR      (128)
  82.  
  83. /* SFS supports Soft links.  When OTYPE_LINK is set and OTYPE_HARDLINK is
  84.    clear then the entry is a soft link.  The path of the soft link isn't
  85.    stored with the directory entry, but instead is stored as the file
  86.    data. */
  87.  
  88.  
  89.  
  90. /* The fsObjectContainer structure is used to hold various Objects which
  91.    have the same parent directory.  Objects always start at 2-byte
  92.    boundaries, which means sometimes a padding byte is inserted between
  93.    2 fsObject structures.
  94.  
  95.    parent:  The node-number of the parent Object.  The node number can be
  96.    used to lookup the BLCK number of the block where the parent Object is
  97.    located.
  98.  
  99.    next:  The next ObjectContainer belonging to this directory or zero if
  100.    it is the last in the chain.
  101.  
  102.    previous:  The previous ObjectContainer belonging to this directory or
  103.    zero if it is the first ObjectContainer.
  104.  
  105.    object:  A variable number of fsObject structures, depending on their
  106.    sizes and on the size of the block.  The next object structure can be
  107.    found by creating a pointer pointing to the name field of the current
  108.    object, then skip 2 strings (name & comment) and if the address is odd,
  109.    adding 1. */
  110.  
  111. struct fsObjectContainer {
  112.   struct fsBlockHeader bheader;
  113.  
  114.   NODE parent;
  115.   BLCK next;
  116.   BLCK previous;   /* 0 for the first block in the directory chain */
  117.  
  118.   struct fsObject object[0];
  119. };
  120.  
  121.  
  122.  
  123. /* fsHashTable is the structure of a HashTable block.  It functions much
  124.    like the HashTable found in FFS, except that it is stored in a seperate
  125.    block.  This block contains a number of hash-chains (about 120 for a
  126.    512 byte block).  Each hash-chain is a chain of Nodes.  Each Node
  127.    contains a BLCK pointer to an Object and the node number of the next
  128.    entry in the hash-chain.
  129.  
  130.    parent:  The node-number of the parent object.
  131.  
  132.    hashentry:  The node-number of the first entry of a specific
  133.    hash-chain. */
  134.  
  135. struct fsHashTable {
  136.   struct fsBlockHeader bheader;
  137.  
  138.   NODE parent;
  139.  
  140.   NODE hashentry[0];
  141. };
  142.  
  143.  
  144.  
  145. struct fsSoftLink {
  146.   struct fsBlockHeader bheader;
  147.  
  148.   NODE parent;
  149.   BLCK next;
  150.   BLCK previous;
  151.  
  152.   UBYTE string[0];
  153. };
  154.  
  155.  
  156.  
  157. struct fsObjectNode {
  158.   struct fsNode node;
  159.   NODE  next;
  160.   UWORD hash16;
  161. };
  162.